package com.zyx.camunda.config;

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.impl.cfg.IdGenerator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>指定自定义雪花生成器作为camunda主键生成器</p>
 *
 * @author Yaxi.Zhang
 * @since 2022/9/6 23:41
 */
@Slf4j
@Configuration
public class IdGeneratorConfig {
    @Bean
    @ConditionalOnMissingBean(IdGenerator.class)
    @ConditionalOnProperty(prefix = "camunda.bpm", name = "id-generator", havingValue = "snowflake", matchIfMissing = true)
    public IdGenerator customerSnowFlakeGenerator() {
        log.info("==========>>>>>>>>>> customerSnowFlakeGenerator <<<<<<<<<<==========");
        return new CustomerSnowFlakeGenerator();
    }
}
